<?php

require_once 'cms/core/om/om/BaseCategory.php';


/**
 * Skeleton subclass for representing a row from the 'category' table.
 *
 * 
 *
 * You should add additional methods to this class to meet the
 * application requirements.  This class will only be generated as
 * long as it does not already exist in the output directory.
 *
 * @package cms.core.om
 */	
class Category extends BaseCategory {

    function getMaxPosition() {

        $con = Propel::getConnection();
        $stmt = $con->createStatement();

        $rs = $stmt->executeQuery(
                "SELECT MAX(position) FROM category " .
                "WHERE module = '". $this->getModule()."'",
                ResultSet::FETCHMODE_NUM
              );

        if($rs->next()) {
            return $rs->getInt(1);
        }
    }
    
    function getCategoryI18n($lang) {
    	require_once 'CategoryI18nPeer.php';
    	$c = new Criteria();
    	$c->add(CategoryI18nPeer::CATEGORY_ID, $this->getCategoryId());
    	$c->add(CategoryI18nPeer::LANGUAGE_CODE, $lang);
    	$c->add(CategoryI18nPeer::ACTIVE, true);
    	return CategoryI18nPeer::doSelectOne($c);    	
    }

} // Category
